<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>上架</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<jsp:include page="${pageContext.request.contextPath }/resource_path.jsp" flush="true"/>
</head>
<body class="layui-anim layui-anim-up">
	<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a>
          <cite>入库记录</cite>
        </a>
      </span>
    </div>
    <div class="x-body">
    <div style="margin-bottom: 18px">
    	<div class="layui-inline">
			<table>
				<tr>
					<td>
						<input class="layui-input" name="keyword" id="keyword1" placeholder="请输入产品码" autocomplete="off" style="display: inline; width: 180px; margin-left: 10px">
					</td>
					<td>
						<input class="layui-input" name="keyword2" id="keyword2" placeholder="请输入简称" autocomplete="off" style="display: inline; width: 180px; margin-left: 10px">
					</td>
				</tr>
			</table>
		</div>
		<button class="layui-btn layui-btn-normal" data-type="reload"><i class="layui-icon layui-icon-search"></i>检索</button>
	  </div>
	  <table class="layui-hide" id="tableList" lay-filter="tableList"></table>
    </div>  
    
    <!-- 详情框 -->
	<div id="detailDiv" hidden>
		<table class="layui-hide" id="tableDetails" lay-filter="tableDetails"></table>
	</div>
	
	
<script type="text/html" id="rowToolbar">
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="detail"><i class="layui-icon layui-icon-search"></i>详细</a>
</script>
<script type="text/javascript">
	layui.use(['table','layer','upload','form','laydate'], function(){
		var table = layui.table;
		var layer = layui.layer;
		var form = layui.form;
		var laydate = layui.laydate;
		
		var $ = layui.jquery, active = {
			reload:function () {
				var keyword1 = $("#keyword1").val();
				var keyword2 = $("#keyword2").val();
				table.reload('contenttable',{
					method:'get',
					where:{
						"materiel_num":keyword1
						,"brevity_num":keyword2
					}
				});
			}
		}
		
		//三级联动
		form.on('select(warehouseId)', function(data){
			//通过仓库id查询库区列表
			var strWhere = 'warehouse_id = '+ data.value + 'and'
			$.ajax({
				type:'post'
				,url:'${pageContext.request.contextPath }/inventoryManagement/selectWarehouseRegionListByWarehouseId.do'
				,data:{'strWhere':strWhere}
				,dataType:'json'
				,success:function(res){
					$("#regionId").find("option").not(":first").remove();
					for(var i = 0;i < res.length;i++){
						$("#regionId").append('<option value="'+res[i].id+'">'+res[i].region_name+'</option>');
					}
					form.render();
				}
			})
		}); 
		form.on('select(regionId)', function(data){
			//通过库区id查询库位列表
			var strWhere = 'region_id = '+ data.value + 'and'
			$.ajax({
				type:'post'
				,url:'${pageContext.request.contextPath }/inventoryManagement/selectWarehouseRegionLocationListByRegionId.do'
				,data:{'strWhere':strWhere}
				,dataType:'json'
				,success:function(res){
					$("#locationId").find("option").not(":first").remove();
					for(var i = 0;i < res.length;i++){
						$("#locationId").append('<option value="'+res[i].id+'">'+res[i].location_name+'</option>');
					}
					form.render();
				}
			})
		}); 
		
		//三级联动(2)
		form.on('select(warehouseId2)', function(data){
			//通过仓库id查询库区列表
			var strWhere = 'warehouse_id = '+ data.value + 'and'
			$.ajax({
				type:'post'
				,url:'${pageContext.request.contextPath }/inventoryManagement/selectWarehouseRegionListByWarehouseId.do'
				,data:{'strWhere':strWhere}
				,dataType:'json'
				,success:function(res){
					$("#regionId2").find("option").not(":first").remove();
					for(var i = 0;i < res.length;i++){
						$("#regionId2").append('<option value="'+res[i].id+'">'+res[i].region_name+'</option>');
					}
					form.render();
				}
			})
		}); 
		form.on('select(regionId2)', function(data){
			//通过库区id查询库位列表
			var strWhere = 'region_id = '+ data.value + 'and'
			$.ajax({
				type:'post'
				,url:'${pageContext.request.contextPath }/inventoryManagement/selectWarehouseRegionLocationListByRegionId.do'
				,data:{'strWhere':strWhere}
				,dataType:'json'
				,success:function(res){
					$("#locationId2").find("option").not(":first").remove();
					for(var i = 0;i < res.length;i++){
						$("#locationId2").append('<option value="'+res[i].id+'">'+res[i].location_name+'</option>');
					}
					form.render();
				}
			})
		}); 
		
		$('.layui-btn').on('click', function(){
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});
		
		
		table.render({
			elem: '#tableList'
			,url:'${pageContext.request.contextPath }/up/list.do'
			,toolbar: '#toolbar'
			,title: 'machineList'
			,id :'contenttable'
			,limits:[10,20,30]
            ,defaultToolbar:['filter', 'print']
			,cols: [
					[
						{type: 'checkbox',fixed: 'left'},
						{field:'id', title:'序号', width: 50,type:'numbers', align:'center'},
						{field:'mid', title:'物料id', align:'center',hide:true},
						{field:'customer_name', title:'供应商名称', align:'center'},
						{field:'materiel_name', title:'物料名称', align:'center'},
						{field:'materiel_num', title:'产品码', align:'center'},
						{field:'brevity_num', title:'简称', align:'center'},
						{field:'pici', title:'批次', align:'center'},
						//{field:'unit', title:'单位', align:'center'},
						/* {field:'container_name', title:'容器名称',edit: 'text', align:'center'},
						{field:'containerNum', title:'容器数量',edit: 'text', align:'center'},
						{field:'is_devanning', title:'是否拆箱',edit: 'text', align:'center'}, 
						{field:'devanning_num', title:'拆箱数',edit: 'text', align:'center'},*/
						//{field:'outgoing_frequency', title:'出货频率',align:'center'},
						{field:'materiel_size', title:'物料规格', align:'center'},
						{field:'materiel_properties', title:'物料型号', align:'center'},
						{field:'number', title:'入库数量（个）', align:'center'},
						//{field:'cqname', title:'仓库',align:'center'},
						{field:'kqname', title:'库区',align:'center'},
						//{field:'kwname', title:'库位',align:'center'},
						{field:'createDate', title:'入库时间', align:'center'}
	                ]
	               ]
			,page: true
			,done : function(){
                $('th').css({
                    'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    'font-size': 10,
                })
            }
		});
		
	
	});
	
	toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
</script>

</body>
</html>